// 入口文件 --- 项目启动的核心文件
import { createApp } from "vue";
import "./style.css";
import "normalize.css";
import App from "./App.vue";
import router from "./router/index.js";
import store from "./store";
import "element-plus/dist/index.css";
import * as ElementPlusIconsVue from "@element-plus/icons-vue";
import AV from "leancloud-storage";
import { ID, KEY, DOMAIN } from "./config";
// LeanCloud初始化
AV.init({
  appId: ID,
  appKey: KEY,
  serverURL: DOMAIN,
});

//尝试提取本地存储用户信息，并存入状态机，方便路由守卫做判断
let info = localStorage.getItem("vue-admin-userinfo");
if (info) {
  store.commit("user/initUserInfoMut", JSON.parse(info));
}

let app = createApp(App);
app.use(store); //注入状态机
app.use(router); //3. 路由注入 ，会向vue的原型链上挂载了一个$router对象

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}
app.mount("#app");
